<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  
  <title>mysql使用笔记 | Hexo</title>
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  <meta name="description" content="预写式日志（Write-Ahead Logging）　　存储引擎在修改表数据时，只修改数据在内存的拷贝，再将该修改行为记录到持久的硬盘上的事物日志中，而不是每次都将数据本身持久化到磁盘。　　事物日志采用追加的方式，因此写日志的操作是磁盘上一小块区域内的顺序I/O，而不像随机I/O需要在磁盘的多个地方移动磁头，所以采用事物日志的方式快很多。事物日志持久以后，内存中被修改的数据在后台可以慢慢的刷回到磁">
<meta property="og:type" content="article">
<meta property="og:title" content="mysql使用笔记">
<meta property="og:url" content="http://yoursite.com/2016/01/22/database/7.mysql使用笔记/index.html">
<meta property="og:site_name" content="Hexo">
<meta property="og:description" content="预写式日志（Write-Ahead Logging）　　存储引擎在修改表数据时，只修改数据在内存的拷贝，再将该修改行为记录到持久的硬盘上的事物日志中，而不是每次都将数据本身持久化到磁盘。　　事物日志采用追加的方式，因此写日志的操作是磁盘上一小块区域内的顺序I/O，而不像随机I/O需要在磁盘的多个地方移动磁头，所以采用事物日志的方式快很多。事物日志持久以后，内存中被修改的数据在后台可以慢慢的刷回到磁">
<meta property="og:updated_time" content="2016-01-29T17:47:36.000Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="mysql使用笔记">
<meta name="twitter:description" content="预写式日志（Write-Ahead Logging）　　存储引擎在修改表数据时，只修改数据在内存的拷贝，再将该修改行为记录到持久的硬盘上的事物日志中，而不是每次都将数据本身持久化到磁盘。　　事物日志采用追加的方式，因此写日志的操作是磁盘上一小块区域内的顺序I/O，而不像随机I/O需要在磁盘的多个地方移动磁头，所以采用事物日志的方式快很多。事物日志持久以后，内存中被修改的数据在后台可以慢慢的刷回到磁">
  
    <link rel="alternative" href="/atom.xml" title="Hexo" type="application/atom+xml">
  
  
    <link rel="icon" href="/favicon.png">
  
  <link href="//fonts.googleapis.com/css?family=Source+Code+Pro" rel="stylesheet" type="text/css">
  <link rel="stylesheet" href="/css/style.css" type="text/css">
  

</head>
<body>
  <div id="container">
    <div id="wrap">
      <header id="header">
  <div id="banner"></div>
  <div id="header-outer" class="outer">
    <div id="header-title" class="inner">
      <h1 id="logo-wrap">
        <a href="/" id="logo">Hexo</a>
      </h1>
      
    </div>
    <div id="header-inner" class="inner">
      <nav id="main-nav">
        <a id="main-nav-toggle" class="nav-icon"></a>
        
          <a class="main-nav-link" href="/">Home</a>
        
          <a class="main-nav-link" href="/archives">Archives</a>
        
      </nav>
      <nav id="sub-nav">
        
          <a id="nav-rss-link" class="nav-icon" href="/atom.xml" title="RSS Feed"></a>
        
        <a id="nav-search-btn" class="nav-icon" title="Search"></a>
      </nav>
      <div id="search-form-wrap">
        <form action="//google.com/search" method="get" accept-charset="UTF-8" class="search-form"><input type="search" name="q" results="0" class="search-form-input" placeholder="Search"><button type="submit" class="search-form-submit">&#xF002;</button><input type="hidden" name="sitesearch" value="http://yoursite.com"></form>
      </div>
    </div>
  </div>
</header>
      <div class="outer">
        <section id="main"><article id="post-database/7.mysql使用笔记" class="article article-type-post" itemscope itemprop="blogPost">
  <div class="article-meta">
    <a href="/2016/01/22/database/7.mysql使用笔记/" class="article-date">
  <time datetime="2016-01-22T08:52:00.000Z" itemprop="datePublished">2016-01-22</time>
</a>
    
  <div class="article-category">
    <a class="article-category-link" href="/categories/database/">database</a>
  </div>

  </div>
  <div class="article-inner">
    
    
      <header class="article-header">
        
  
    <h1 class="article-title" itemprop="name">
      mysql使用笔记
    </h1>
  

      </header>
    
    <div class="article-entry" itemprop="articleBody">
      
        <h2 id="u9884_u5199_u5F0F_u65E5_u5FD7_uFF08Write-Ahead_Logging_uFF09"><a href="#u9884_u5199_u5F0F_u65E5_u5FD7_uFF08Write-Ahead_Logging_uFF09" class="headerlink" title="预写式日志（Write-Ahead Logging）"></a>预写式日志（Write-Ahead Logging）</h2><p>　　存储引擎在修改表数据时，只修改数据在内存的拷贝，再将该修改行为记录到持久的硬盘上的事物日志中，而不是每次都将数据本身持久化到磁盘。<br>　　事物日志采用追加的方式，因此写日志的操作是磁盘上一小块区域内的顺序I/O，而不像随机I/O需要在磁盘的多个地方移动磁头，所以采用事物日志的方式快很多。事物日志持久以后，内存中被修改的数据在后台可以慢慢的刷回到磁盘中。这种方式称为预写式日志（Write-Ahead Logging），修改数据需要写两次磁盘。<br>　　事物日志已经持久化，但数据未刷入磁盘。系统崩溃，再次启动时，存储引擎自动恢复这部分数据</p>
<h2 id="u8FDC_u7A0B_u8BBF_u95EE"><a href="#u8FDC_u7A0B_u8BBF_u95EE" class="headerlink" title="远程访问"></a>远程访问</h2><p>　　Mysql默认是不可以通过远程机器访问的，通过下面的配置可以开启远程访问<br><figure class="highlight"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br></pre></td><td class="code"><pre><span class="line">#命令行下mysql -uroot -p 进入到mysql客户端</span><br><span class="line">&gt; use mysql;</span><br><span class="line">&gt; GRANT ALL ON *.* TO admin@'%' IDENTIFIED BY 'admin' WITH GRANT OPTION;</span><br><span class="line">#含义：允许任何IP地址（上面的 % 就是这个意思）的电脑用admin帐户和密码（admin）来访问这个MySQL Server</span><br><span class="line">#root帐户是默认无法远程登陆的，做以下调整即可</span><br><span class="line">&gt; GRANT ALL ON *.* TO root@'%' IDENTIFIED BY 'root' WITH GRANT OPTION;</span><br><span class="line"></span><br><span class="line">#注意：% 不包括localhost</span><br><span class="line">#异常如下：ERROR 1045 (28000): Access denied for user 'admin'@'localhost' (using password: YES)</span><br><span class="line">#在mysql中输入如下命令即可解决</span><br><span class="line">&gt; GRANT ALL ON *.* TO admin@'localhost' IDENTIFIED BY 'admin' WITH GRANT OPTION;</span><br><span class="line"></span><br><span class="line">#查询mysql的用户，可能需要先执行 flush privileges;命令</span><br><span class="line">&gt; select host,user,password from mysql.user;</span><br><span class="line">#flush privileges表示从grant表中重新加载权限数据。因为MySQL把权限都放在了cache中，所以在做完更改后需要重新加载。</span><br></pre></td></tr></table></figure></p>
<h2 id="u6570_u5B57_u7C7B_u578B"><a href="#u6570_u5B57_u7C7B_u578B" class="headerlink" title="数字类型"></a>数字类型</h2><p>　　mysql有多种数字类型，主要有int、bigint、smallint和tinyint</p>
<table>
<thead>
<tr>
<th style="text-align:left">类型</th>
<th style="text-align:left">说明</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left">bigint</td>
<td style="text-align:left">从 -2^63 到 2^63-1 的整型数据。<strong>8个字节</strong>。<br>在mysql建表中的length，只是用于显示的位数</td>
</tr>
<tr>
<td style="text-align:left">int</td>
<td style="text-align:left">从 -2^31 到 2^31 – 1 的整型数据。<strong>4个字节</strong>。<br>int 的 SQL-92 同义字为 integer</td>
</tr>
<tr>
<td style="text-align:left">smallint</td>
<td style="text-align:left">从 -2^15 到 2^15–1 的整型数据。存储大小为 2 个字节</td>
</tr>
<tr>
<td style="text-align:left">tinyint</td>
<td style="text-align:left">从 0 到 255 的整型数据，存储大小为 1 字节</td>
</tr>
</tbody>
</table>
<p>　　注意：int(M) 在 integer 数据类型中，M 表示最大显示宽度。M 的值跟 int(M)所占多少存储空间并无任何关系，和数字位数也无关系。int(3)、int(4)、int(8) 在磁盘上都是占用 4 btyes 的存储空间</p>
<h2 id="u6570_u636E_u5BFC_u51FA"><a href="#u6570_u636E_u5BFC_u51FA" class="headerlink" title="数据导出"></a>数据导出</h2><figure class="highlight"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">-- &#21629;&#20196;&#34892;&#19979;&#29992;&#27861;&#65306;mysqldump -u&#29992;&#25143;&#21517; -p&#23494;&#30721; -d &#25968;&#25454;&#24211;&#21517; &#34920;&#21517; &#33050;&#26412;&#21517;;&#10;&#10;-- &#23548;&#20986;&#24211;&#30340;&#34920;&#21644;&#35270;&#22270;&#31561;&#32467;&#26500;&#65288;&#20854;&#20013;&#29992;&#25142;&#21517;&#28858;root,&#23494;&#30721;&#28858;dbpasswd&#65292;&#29983;&#25104;&#30340;&#33050;&#26412;&#21517;&#28858;db.sql&#65289;&#10;&#62; mysqldump -u root -p dbpasswd -d &#25968;&#25454;&#24211;&#21517; &#62; db.sql;&#10;&#10;-- &#23548;&#20986;&#24211;&#30340;&#26576;&#24352;&#34920;(test)&#32467;&#26500;&#10;&#62; mysqldump -u root -p dbpasswd -d &#25968;&#25454;&#24211;&#21517; test &#62; db.sql;&#10;&#10;-- &#23548;&#20986;&#34920;(test)&#25968;&#25454;&#10;&#62; mysqldump -u root -p dbpasswd  -t &#25968;&#25454;&#24211;&#21517; test &#62; db.sql;&#10;&#10;-- &#23548;&#20986;&#34920;&#32467;&#26500;&#21450;&#25968;&#25454;&#65288;&#19981;&#21152;-d, -t&#65289;&#10;&#62; mysqldump -u root -p dbpasswd  &#25968;&#25454;&#24211;&#21517; &#62; db.sql;&#10;&#10;-- &#23548;&#20986;&#25968;&#25454;&#24211;&#20026;dbname&#26576;&#24352;&#34920;(test)&#32467;&#26500;&#21450;&#34920;&#25968;&#25454;&#65288;&#19981;&#21152;-d&#65289;&#10;&#62; mysqldump -uroot -pdbpasswd dbname test &#62; db.sql;&#10;&#10;-- --where/-w&#21442;&#25968;&#21487;&#20197;&#35774;&#23450;&#25968;&#25454;&#23548;&#20986;&#30340;&#26465;&#20214;&#65292;&#20351;&#29992;&#26041;&#24335;&#21644;SQL&#26597;&#35810;&#21629;&#20196;&#20013;&#20013;&#30340;where&#22522;&#26412;&#19978;&#30456;&#21516;&#10;&#62; mysqldump -u&#29992;&#25143;&#21517; -p&#23494;&#30721; &#25968;&#25454;&#24211;&#21517; &#34920;&#21517; --where=&#34;&#31579;&#36873;&#26465;&#20214;&#34; &#62; &#23548;&#20986;&#25991;&#20214;&#36335;&#24452;&#10;&#10;-- &#20174;meteo&#25968;&#25454;&#24211;&#30340;sdata&#34920;&#20013;&#23548;&#20986;sensorid=11 &#19988; fieldid=0&#30340;&#25968;&#25454;&#21040; /home/xyx/Temp.sql &#36825;&#20010;&#25991;&#20214;&#20013;&#10;&#62; mysqldump -uroot -p123456 meteo sdata --where=&#34; sensorid=11 and fieldid=0&#34; &#62; /home/xyx/Temp.sql&#10;&#10;-- &#30452;&#25509;&#23548;&#20986;&#25991;&#26412;&#25991;&#20214;*.txt&#10;&#62; mysqldump -uroot -p123456 meteo sdata --where=&#34; sensorid=11 and fieldid=0&#34; &#62; /home/xyx/Temp.txt</span><br></pre></td></tr></table></figure>
<h2 id="u5B58_u50A8_u8FC7_u7A0B"><a href="#u5B58_u50A8_u8FC7_u7A0B" class="headerlink" title="存储过程"></a>存储过程</h2><figure class="highlight"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br></pre></td><td class="code"><pre><span class="line">CREATE TABLE employees (</span><br><span class="line">    id INT NOT NULL,</span><br><span class="line">    fname VARCHAR(30),</span><br><span class="line">    lname VARCHAR(30),</span><br><span class="line">    hired DATE NOT NULL DEFAULT '1970-01-01',</span><br><span class="line">    separated DATE NOT NULL DEFAULT '9999-12-31',</span><br><span class="line">    job_code INT,</span><br><span class="line">    store_id INT</span><br><span class="line">);</span><br><span class="line">/*  </span><br><span class="line">在使用复合语句时，必须解决这样一个问题： 复合语句块里的语句必须以分号（;）彼此隔开，但分号同时也是mysql程序默认使用的语句分隔符，所以在使用mysql程序定义存储过程时会发生冲突。解决这个问题的办法是:使用delimiter命令把sql语句分隔符重定义为另一字符或字符串，且必须是在存储过程定义里没有出现过的。</span><br><span class="line">*/</span><br><span class="line">DELIMITER $$</span><br><span class="line">DROP PROCEDURE IF EXISTS SampleProc$$</span><br><span class="line">CREATE PROCEDURE SampleProc()</span><br><span class="line">    BEGIN</span><br><span class="line">        DECLARE x INT;</span><br><span class="line">        SET x = 1000;</span><br><span class="line">        WHILE x&lt;= 2000 DO</span><br><span class="line">            insert into employees(id,fname,lname,hired,separated,job_code,store_id) values(x,concat('firstname',x),concat('ai',x),'1994-01-01','1995-01-01',10,20);</span><br><span class="line">            SET  x = x + 1;</span><br><span class="line">        END WHILE;</span><br><span class="line">    END$$</span><br><span class="line">     </span><br><span class="line">/*执行存储过程*/</span><br><span class="line">call SampleProc() $$</span><br><span class="line">delimiter ;</span><br></pre></td></tr></table></figure>
<h4 id="u52A8_u6001_u5EFA_u8868"><a href="#u52A8_u6001_u5EFA_u8868" class="headerlink" title="动态建表"></a>动态建表</h4><figure class="highlight sql"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">-- 按messageId动态建表，存储其推送信息</span></span><br><span class="line">DELIMITER $$</span><br><span class="line"><span class="operator"><span class="keyword">DROP</span> <span class="keyword">PROCEDURE</span> <span class="keyword">IF</span> <span class="keyword">EXISTS</span> MessagePushInfoProcedure$$</span><br><span class="line"><span class="keyword">CREATE</span> <span class="keyword">PROCEDURE</span> MessagePushInfoProcedure(<span class="keyword">in</span> messageId <span class="built_in">varchar</span>(<span class="number">32</span>))</span><br><span class="line"><span class="keyword">BEGIN</span></span><br><span class="line">  <span class="keyword">declare</span> table_prefix <span class="built_in">varchar</span>(<span class="number">20</span>);</span></span><br><span class="line">  <span class="operator"><span class="keyword">set</span> table_prefix=<span class="string">'t_message_push_info_'</span>;</span></span><br><span class="line">  <span class="operator"><span class="keyword">set</span> @table_name = <span class="keyword">concat</span>(table_prefix, messageId);</span> </span><br><span class="line">  <span class="comment">-- set @dropSql = concat('DROP TABLE IF EXISTS ', @table_name);</span></span><br><span class="line">  <span class="operator"><span class="keyword">set</span> @createSql = <span class="keyword">concat</span>(<span class="string">'CREATE TABLE IF NOT EXISTS '</span>, @table_name, </span><br><span class="line">        <span class="string">'(id varchar(32) NOT NULL,</span><br><span class="line">           api_key varchar(45) DEFAULT NULL,</span><br><span class="line">           device_id varchar(32) DEFAULT NULL,</span><br><span class="line">           message_id varchar(32) DEFAULT NULL,</span><br><span class="line">           message_status int(11) DEFAULT NULL,</span><br><span class="line">           receive_time datetime DEFAULT NULL,</span><br><span class="line">           operate_type int(11) DEFAULT NULL,</span><br><span class="line">           operate_time datetime DEFAULT NULL,</span><br><span class="line">           PRIMARY KEY (id)</span><br><span class="line">         ) ENGINE=MyISAM DEFAULT CHARSET=utf8;'</span>);</span></span><br><span class="line"><span class="comment">-- prepare dropStmt from @dropSql;</span></span><br><span class="line"><span class="comment">-- execute dropStmt;</span></span><br><span class="line"><span class="operator"><span class="keyword">prepare</span> createStmt <span class="keyword">from</span> @createSql;</span></span><br><span class="line"><span class="operator"><span class="keyword">execute</span> createStmt;</span></span><br><span class="line"><span class="operator"><span class="keyword">END</span>$$</span><br><span class="line"><span class="comment">-- 执行存储过程</span></span><br><span class="line"><span class="comment">-- call MessagePushInfoProcedure('aaaa') $$</span></span><br><span class="line">delimiter ;</span></span><br></pre></td></tr></table></figure>
<h2 id="u65E5_u671F_u64CD_u4F5C"><a href="#u65E5_u671F_u64CD_u4F5C" class="headerlink" title="日期操作"></a>日期操作</h2><figure class="highlight sql"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br></pre></td><td class="code"><pre><span class="line">#查询当前日期，输出'2015-02-02'</span><br><span class="line"><span class="operator"><span class="keyword">select</span> <span class="keyword">curdate</span>() <span class="keyword">from</span> dual;</span></span><br><span class="line"></span><br><span class="line">#查询7天前日期，输出'2015-01-26'</span><br><span class="line"><span class="operator"><span class="keyword">select</span> <span class="keyword">date_sub</span>(<span class="keyword">curdate</span>(), <span class="built_in">INTERVAL</span> <span class="number">7</span> <span class="keyword">DAY</span>) <span class="keyword">from</span> dual;</span></span><br><span class="line"></span><br><span class="line">#查询当前的年月 输出'201502'</span><br><span class="line"><span class="operator"><span class="keyword">select</span> <span class="keyword">date_format</span>(<span class="keyword">curdate</span>(), <span class="string">'%Y%m'</span>) <span class="keyword">from</span> dual;</span></span><br><span class="line"></span><br><span class="line">#获取TIMESTAMP类型字段(包括年月日时分秒)的日期部分，输出'2015-02-02' '2015-02-01'</span><br><span class="line"><span class="operator"><span class="keyword">select</span> <span class="built_in">date</span>(F_Time) <span class="keyword">from</span> T_TimeTest;</span></span><br><span class="line"></span><br><span class="line">#查询今天的记录</span><br><span class="line"><span class="operator"><span class="keyword">select</span> * <span class="keyword">from</span> T_TimeTest <span class="keyword">where</span> <span class="keyword">to_days</span>(F_Time) = <span class="keyword">to_days</span>(<span class="keyword">now</span>());</span></span><br><span class="line"></span><br><span class="line">#查询昨天的记录</span><br><span class="line">#now() 能获得当前的日期时间</span><br><span class="line">#current_timestamp、localtime、localtimestamp等日期时间函数等同于now()</span><br><span class="line">#鉴于now()函数简短易记，建议使用now()来替代上面列出的函数。</span><br><span class="line"><span class="operator"><span class="keyword">select</span> * <span class="keyword">from</span> T_TimeTest <span class="keyword">where</span> <span class="keyword">to_days</span>(<span class="keyword">now</span>()) - <span class="keyword">to_days</span>(F_Time) = <span class="number">1</span>;</span></span><br><span class="line">#基本等价于下面的语句，但是如果有日期在当前日期之后（未来日期），该记录也会输出</span><br><span class="line"><span class="operator"><span class="keyword">select</span> * <span class="keyword">from</span> T_TimeTest <span class="keyword">where</span> <span class="keyword">date_sub</span>(<span class="keyword">curdate</span>(), <span class="built_in">INTERVAL</span> <span class="number">1</span> <span class="keyword">DAY</span>) &lt;= <span class="built_in">date</span>(F_Time);</span></span><br><span class="line"></span><br><span class="line">#查询最近7天的记录，也会输出未来日期</span><br><span class="line"><span class="operator"><span class="keyword">select</span> * <span class="keyword">from</span> T_TimeTest <span class="keyword">where</span> <span class="keyword">date_sub</span>(<span class="keyword">curdate</span>(), <span class="built_in">INTERVAL</span> <span class="number">7</span> <span class="keyword">DAY</span>) &lt;= <span class="built_in">date</span>(F_Time);</span></span><br><span class="line"></span><br><span class="line">#查询本月的信息记录：</span><br><span class="line"><span class="operator"><span class="keyword">select</span> * <span class="keyword">from</span> T_TimeTest <span class="keyword">where</span> <span class="keyword">date_format</span>(F_Time, <span class="string">'%Y%m'</span>) = <span class="keyword">date_format</span>(<span class="keyword">curdate</span>() , <span class="string">'%Y%m'</span>);</span></span><br><span class="line"></span><br><span class="line">#查询上一月的信息记录：</span><br><span class="line"><span class="operator"><span class="keyword">select</span> * <span class="keyword">from</span> T_TimeTest <span class="keyword">where</span> <span class="keyword">period_diff</span>(<span class="keyword">date_format</span>(<span class="keyword">now</span>() , <span class="string">'%Y%m'</span>) , <span class="keyword">date_format</span>(F_Time, <span class="string">'%Y%m'</span>)) = <span class="number">1</span>;</span></span><br></pre></td></tr></table></figure>
<p>　　<strong>to_days</strong>：将具体的某一个日期或时间字符串转换到某一天所对应的unix时间戳，2015.1.22日与2015.1.23日的差别就是，转换之后的数增加了1，这个粒度的查询是比较粗糙的，可以采用细粒度的查询方法str_to_date。<br>　　注意：其不用于阳历出现(1582)前的值，原因是当日历改变时，遗失的日期不会被考虑在内。因此对于1582年之前的日期(或许在其它地区为下一年 )，该函数的结果实不可靠的。MySQL”日期和时间类型”中的规则是将日期中的二位数年份值转化为四位。因此对于’1997-10-07’和’97-10-07’将被视为同样的日期:<br>　　<strong>str_to_date</strong>：把字符串时间完全的翻译过来<br><figure class="highlight sql"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">-- 输出2010-11-23 14:39:51</span></span><br><span class="line"><span class="operator"><span class="keyword">select</span> <span class="keyword">str_to_date</span>(<span class="string">"2010-11-23 14:39:51"</span>,<span class="string">'%Y-%m-%d %H:%i:%s'</span>);</span></span><br><span class="line"><span class="operator"><span class="keyword">select</span> <span class="keyword">str_to_date</span>(article.<span class="string">`add_time`</span>,<span class="string">'%Y-%m-%d %H:%i:%s'</span>)</span><br><span class="line">    <span class="keyword">from</span> article  </span><br><span class="line">    <span class="keyword">where</span> <span class="keyword">str_to_date</span>(article.<span class="string">`add_time`</span>,<span class="string">'%Y-%m-%d %H:%i:%s'</span>)&gt;=<span class="string">'2012-06-28 08:00:00'</span> <span class="keyword">and</span> <span class="keyword">str_to_date</span>(article.<span class="string">`add_time`</span>,<span class="string">'%Y-%m-%d %H:%i:%s'</span>)&lt;=<span class="string">'2012-06-28 09:59:59'</span>;</span></span><br></pre></td></tr></table></figure></p>
<h2 id="u5B9A_u65F6_u4EFB_u52A1"><a href="#u5B9A_u65F6_u4EFB_u52A1" class="headerlink" title="定时任务"></a>定时任务</h2><p>　　自MySQL5.1.6起，增加了事件调度器(Event Scheduler)，用做定时任务执行（例如：删除记录等等），可以精确到每秒钟执行一个任务。事件调度器也可称为临时触发器(temporal triggers)，因为事件调度器是基于特定时间周期触发来执行某些任务，而触发器(Triggers)是基于某个表所产生的事件触发的，区别也就在这里。</p>
<h4 id="u5F00_u542Fevent_scheduler"><a href="#u5F00_u542Fevent_scheduler" class="headerlink" title="开启event_scheduler"></a>开启event_scheduler</h4><p>　　1. SET GLOBAL event_scheduler = 1; – mysql服务重启后失效<br>　　2. 在配置my.cnf文件中加上 event_scheduler = 1<br>　　3. SET GLOBAL event_scheduler = ON;<br>　　4. 在启动命令加上“–event_scheduler=1”，例如：mysqld … –event_scheduler=1</p>
<h4 id="u67E5_u770Bevent_scheduler_u72B6_u6001"><a href="#u67E5_u770Bevent_scheduler_u72B6_u6001" class="headerlink" title="查看event_scheduler状态"></a>查看event_scheduler状态</h4><p>　　1. SHOW VARIABLES LIKE ‘event_scheduler’;<br>　　2. SELECT @@event_scheduler;</p>
<h4 id="u521B_u5EFA_u4E8B_u4EF6"><a href="#u521B_u5EFA_u4E8B_u4EF6" class="headerlink" title="创建事件"></a>创建事件</h4><figure class="highlight"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br><span class="line">75</span><br><span class="line">76</span><br><span class="line">77</span><br><span class="line">78</span><br><span class="line">79</span><br><span class="line">80</span><br><span class="line">81</span><br><span class="line">82</span><br><span class="line">83</span><br><span class="line">84</span><br><span class="line">85</span><br><span class="line">86</span><br><span class="line">87</span><br><span class="line">88</span><br><span class="line">89</span><br><span class="line">90</span><br><span class="line">91</span><br><span class="line">92</span><br><span class="line">93</span><br><span class="line">94</span><br><span class="line">95</span><br><span class="line">96</span><br><span class="line">97</span><br><span class="line">98</span><br><span class="line">99</span><br><span class="line">100</span><br><span class="line">101</span><br><span class="line">102</span><br><span class="line">103</span><br><span class="line">104</span><br><span class="line">105</span><br><span class="line">106</span><br><span class="line">107</span><br><span class="line">108</span><br></pre></td><td class="code"><pre><span class="line">-- 示例，每秒插入一条记录到数据表</span><br><span class="line">CREATE TABLE aaa (timeline TIMESTAMP);</span><br><span class="line"> </span><br><span class="line">CREATE EVENT e_test_insert</span><br><span class="line">    ON SCHEDULE EVERY 1 SECOND</span><br><span class="line">    DO INSERT INTO aaa VALUES(CURRENT_TIMESTAMP);</span><br><span class="line"></span><br><span class="line">-- 5天后清空test表</span><br><span class="line">CREATE EVENT e_test</span><br><span class="line">    ON SCHEDULE AT CURRENT_TIMESTAMP + INTERVAL 5 DAY</span><br><span class="line">    DO TRUNCATE TABLE test.aaa;</span><br><span class="line"></span><br><span class="line">-- 2007年7月20日12点整清空test表</span><br><span class="line">CREATE EVENT e_test</span><br><span class="line">    ON SCHEDULE AT TIMESTAMP '2007-07-20 12:00:00'</span><br><span class="line">    DO TRUNCATE TABLE test.aaa;</span><br><span class="line"></span><br><span class="line">-- 每天定时清空test表</span><br><span class="line">CREATE EVENT e_test</span><br><span class="line">    ON SCHEDULE EVERY 1 DAY</span><br><span class="line">    DO TRUNCATE TABLE test.aaa;</span><br><span class="line"></span><br><span class="line">-- 5天后开启每天定时清空test表</span><br><span class="line">CREATE EVENT e_test</span><br><span class="line">    ON SCHEDULE EVERY 1 DAY</span><br><span class="line">    STARTS CURRENT_TIMESTAMP + INTERVAL 5 DAY</span><br><span class="line">    DO TRUNCATE TABLE test.aaa;</span><br><span class="line"></span><br><span class="line">-- 每天定时清空test表，5天后停止执行</span><br><span class="line">CREATE EVENT e_test</span><br><span class="line">    ON SCHEDULE EVERY 1 DAY</span><br><span class="line">    ENDS CURRENT_TIMESTAMP+ INTERVAL 5 DAY</span><br><span class="line">    DO TRUNCATE TABLE test.aaa;</span><br><span class="line"></span><br><span class="line">-- 5天后开启每天定时清空test表，一个月后停止执行</span><br><span class="line">CREATE EVENT e_test</span><br><span class="line">    ON SCHEDULE EVERY 1 DAY</span><br><span class="line">    STARTS CURRENT_TIMESTAMP + INTERVAL 5 DAY</span><br><span class="line">    ENDS CURRENT_TIMESTAMP + INTERVAL 1 MONTH</span><br><span class="line">    DO TRUNCATE TABLE test.aaa;</span><br><span class="line"></span><br><span class="line">-- 每天定时清空test表(只执行一次，任务完成后就终止该事件</span><br><span class="line">CREATE EVENT e_test</span><br><span class="line">    ON SCHEDULE EVERY 1 DAY</span><br><span class="line">    ON COMPLETION NOT PRESERVE</span><br><span class="line">    DO TRUNCATE TABLE test.aaa;</span><br><span class="line"></span><br><span class="line">-- 临时关闭事件</span><br><span class="line">ALTER EVENT e_test DISABLE;</span><br><span class="line"></span><br><span class="line">-- 开启事件</span><br><span class="line">ALTER EVENT e_test ENABLE;</span><br><span class="line"></span><br><span class="line">-- 将每天清空test表改为5天清空一次</span><br><span class="line">ALTER EVENT e_test</span><br><span class="line">    ON SCHEDULE EVERY 5 DAY;</span><br><span class="line"></span><br><span class="line">-- 定时执行存储过程</span><br><span class="line">CREATE TABLE employees (</span><br><span class="line">    id INT NOT NULL primary key auto_increment,</span><br><span class="line">    fname VARCHAR(30)</span><br><span class="line">);</span><br><span class="line"></span><br><span class="line">DELIMITER $$</span><br><span class="line">DROP PROCEDURE IF EXISTS SampleProc$$</span><br><span class="line">CREATE PROCEDURE SampleProc()</span><br><span class="line">    BEGIN</span><br><span class="line">        DECLARE x INT;</span><br><span class="line">        SET x = 1;</span><br><span class="line">        WHILE x&lt;= 2 DO</span><br><span class="line">            insert into employees(fname) values(concat('firstname',x));</span><br><span class="line">            SET  x = x + 1;</span><br><span class="line">        END WHILE;</span><br><span class="line">    END$$</span><br><span class="line">/*执行存储过程*/</span><br><span class="line">-- call SampleProc() $$</span><br><span class="line">delimiter ;</span><br><span class="line"> </span><br><span class="line">CREATE EVENT e_test_insert</span><br><span class="line">    ON SCHEDULE EVERY 5 SECOND</span><br><span class="line">    DO call SampleProc();</span><br><span class="line"></span><br><span class="line">-- 利用 event scheduler 的特性，每秒钟调用一次存储过程，</span><br><span class="line">-- 用于判断SLAVE是否正常运行，如果发现 SLAVE 关闭了，忽略0次错误，然后重新启动SLAVE</span><br><span class="line">delimiter //</span><br><span class="line">create  procedure Slave_Monitor()</span><br><span class="line">begin</span><br><span class="line">    SELECT VARIABLE_VALUE INTO @SLAVE_STATUS </span><br><span class="line">    FROM information_schema.GLOBAL_STATUS</span><br><span class="line">    WHERE VARIABLE_NAME = 'SLAVE_RUNNING';</span><br><span class="line">    IF ('ON'!= @SLAVE_STATUS) THEN</span><br><span class="line">        SET GLOBAL SQL_SLAVE_SKIP_COUNTER = 0;</span><br><span class="line">        SLAVE START;</span><br><span class="line">    END IF;</span><br><span class="line">end //</span><br><span class="line">delimiter ;</span><br><span class="line"> </span><br><span class="line">-- 由于存储过程中无法调用类似 SHOW SLAVE STATUS 这样的语句，</span><br><span class="line">-- 因此无法得到确切的复制错误信息和错误代码，</span><br><span class="line">-- 不能进一步的处理 SLAVE 停止的各种情况。</span><br><span class="line"> </span><br><span class="line">CREATE EVENT IF NOT EXISTS `Slave_Monitor`</span><br><span class="line">    ON SCHEDULE EVERY 5 SECOND</span><br><span class="line">    ON COMPLETION PRESERVE</span><br><span class="line">    DO CALL Slave_Monitor();</span><br><span class="line"> </span><br><span class="line">alter event `Slave_Monitor` ON COMPLETION PRESERVE ENABLE;</span><br><span class="line">alter event `Slave_Monitor` ON COMPLETION PRESERVE DISABLE;</span><br></pre></td></tr></table></figure>
<h2 id="u53C2_u8003_u94FE_u63A5"><a href="#u53C2_u8003_u94FE_u63A5" class="headerlink" title="参考链接"></a>参考链接</h2><p><a href="http://blog.csdn.net/xin_yu_xin/article/details/7574662" target="_blank" rel="external">http://blog.csdn.net/xin_yu_xin/article/details/7574662</a></p>

      
    </div>
    <footer class="article-footer">
      <a data-url="http://yoursite.com/2016/01/22/database/7.mysql使用笔记/" data-id="cijzzpvh700gb1cfs8ymb8txo" class="article-share-link">Share</a>
      
      
  <ul class="article-tag-list"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/database/">database</a></li></ul>

    </footer>
  </div>
  
    
<nav id="article-nav">
  
    <a href="/2016/01/24/database/8.mysql性能分析/" id="article-nav-newer" class="article-nav-link-wrap">
      <strong class="article-nav-caption">Newer</strong>
      <div class="article-nav-title">
        
          mysql性能分析
        
      </div>
    </a>
  
  
    <a href="/2016/01/22/database/6.mysql编译安装/" id="article-nav-older" class="article-nav-link-wrap">
      <strong class="article-nav-caption">Older</strong>
      <div class="article-nav-title">mysql编译安装</div>
    </a>
  
</nav>

  
</article>

</section>
        
          <aside id="sidebar">
  
    
  <div class="widget-wrap">
    <h3 class="widget-title">Categories</h3>
    <div class="widget">
      <ul class="category-list"><li class="category-list-item"><a class="category-list-link" href="/categories/cache/">cache</a><span class="category-list-count">3</span></li><li class="category-list-item"><a class="category-list-link" href="/categories/database/">database</a><span class="category-list-count">13</span></li><li class="category-list-item"><a class="category-list-link" href="/categories/docker/">docker</a><span class="category-list-count">6</span></li><li class="category-list-item"><a class="category-list-link" href="/categories/gis/">gis</a><span class="category-list-count">4</span></li><li class="category-list-item"><a class="category-list-link" href="/categories/git/">git</a><span class="category-list-count">2</span></li><li class="category-list-item"><a class="category-list-link" href="/categories/go/">go</a><span class="category-list-count">1</span></li><li class="category-list-item"><a class="category-list-link" href="/categories/gradle/">gradle</a><span class="category-list-count">1</span></li><li class="category-list-item"><a class="category-list-link" href="/categories/groovy/">groovy</a><span class="category-list-count">1</span></li><li class="category-list-item"><a class="category-list-link" href="/categories/hadoop/">hadoop</a><span class="category-list-count">1</span></li><li class="category-list-item"><a class="category-list-link" href="/categories/java/">java</a><span class="category-list-count">18</span></li><li class="category-list-item"><a class="category-list-link" href="/categories/linux/">linux</a><span class="category-list-count">4</span></li><li class="category-list-item"><a class="category-list-link" href="/categories/log/">log</a><span class="category-list-count">11</span></li><li class="category-list-item"><a class="category-list-link" href="/categories/mongodb/">mongodb</a><span class="category-list-count">14</span></li><li class="category-list-item"><a class="category-list-link" href="/categories/mq/">mq</a><span class="category-list-count">6</span></li><li class="category-list-item"><a class="category-list-link" href="/categories/mybatis/">mybatis</a><span class="category-list-count">9</span></li><li class="category-list-item"><a class="category-list-link" href="/categories/netty/">netty</a><span class="category-list-count">1</span></li><li class="category-list-item"><a class="category-list-link" href="/categories/nginx/">nginx</a><span class="category-list-count">3</span></li><li class="category-list-item"><a class="category-list-link" href="/categories/nio/">nio</a><span class="category-list-count">19</span></li><li class="category-list-item"><a class="category-list-link" href="/categories/nodejs/">nodejs</a><span class="category-list-count">1</span></li><li class="category-list-item"><a class="category-list-link" href="/categories/redis/">redis</a><span class="category-list-count">6</span></li><li class="category-list-item"><a class="category-list-link" href="/categories/rpc/">rpc</a><span class="category-list-count">14</span></li><li class="category-list-item"><a class="category-list-link" href="/categories/spring/">spring</a><span class="category-list-count">5</span></li><li class="category-list-item"><a class="category-list-link" href="/categories/tomcat/">tomcat</a><span class="category-list-count">2</span></li><li class="category-list-item"><a class="category-list-link" href="/categories/zookeeper/">zookeeper</a><span class="category-list-count">2</span></li><li class="category-list-item"><a class="category-list-link" href="/categories/杂项/">杂项</a><span class="category-list-count">2</span></li></ul>
    </div>
  </div>

  
    
  <div class="widget-wrap">
    <h3 class="widget-title">Tags</h3>
    <div class="widget">
      <ul class="tag-list"><li class="tag-list-item"><a class="tag-list-link" href="/tags/aop/">aop</a><span class="tag-list-count">8</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/aspectj/">aspectj</a><span class="tag-list-count">3</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/cache/">cache</a><span class="tag-list-count">3</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/classloader/">classloader</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/common-loggings/">common-loggings</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/commonjs/">commonjs</a><span class="tag-list-count">4</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/database/">database</a><span class="tag-list-count">10</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/docker/">docker</a><span class="tag-list-count">6</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/dubbo/">dubbo</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/fastdfs/">fastdfs</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/gclib/">gclib</a><span class="tag-list-count">2</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/geohash/">geohash</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/gis/">gis</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/git/">git</a><span class="tag-list-count">2</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/go/">go</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/gradle/">gradle</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/groovy/">groovy</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/hadoop/">hadoop</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/hessisan/">hessisan</a><span class="tag-list-count">3</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/java/">java</a><span class="tag-list-count">48</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/javassist/">javassist</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/kafka/">kafka</a><span class="tag-list-count">3</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/linux/">linux</a><span class="tag-list-count">4</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/log/">log</a><span class="tag-list-count">11</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/log4j/">log4j</a><span class="tag-list-count">4</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/logback/">logback</a><span class="tag-list-count">5</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/map/">map</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/memecached/">memecached</a><span class="tag-list-count">2</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/mina/">mina</a><span class="tag-list-count">5</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/mongodb/">mongodb</a><span class="tag-list-count">14</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/mq/">mq</a><span class="tag-list-count">6</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/mqtt/">mqtt</a><span class="tag-list-count">2</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/mybatis/">mybatis</a><span class="tag-list-count">9</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/netty/">netty</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/nginx/">nginx</a><span class="tag-list-count">3</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/nio/">nio</a><span class="tag-list-count">5</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/nodejs/">nodejs</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/postgresql/">postgresql</a><span class="tag-list-count">2</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/protobuf/">protobuf</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/proxy/">proxy</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/push/">push</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/rabbitmq/">rabbitmq</a><span class="tag-list-count">3</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/redis/">redis</a><span class="tag-list-count">6</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/rpc/">rpc</a><span class="tag-list-count">14</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/sitemesh/">sitemesh</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/sld/">sld</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/slf4j/">slf4j</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/socket/">socket</a><span class="tag-list-count">7</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/spatialite-for-android/">spatialite for android</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/spi/">spi</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/spring/">spring</a><span class="tag-list-count">13</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/tomcat/">tomcat</a><span class="tag-list-count">2</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/transaction/">transaction</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/web/">web</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/xSocket/">xSocket</a><span class="tag-list-count">7</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/zbus/">zbus</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/zookeeper/">zookeeper</a><span class="tag-list-count">2</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/数据结构/">数据结构</a><span class="tag-list-count">2</span></li></ul>
    </div>
  </div>

  
    
  <div class="widget-wrap">
    <h3 class="widget-title">Tag Cloud</h3>
    <div class="widget tagcloud">
      <a href="/tags/aop/" style="font-size: 15.38px;">aop</a> <a href="/tags/aspectj/" style="font-size: 11.54px;">aspectj</a> <a href="/tags/cache/" style="font-size: 11.54px;">cache</a> <a href="/tags/classloader/" style="font-size: 10px;">classloader</a> <a href="/tags/common-loggings/" style="font-size: 10px;">common-loggings</a> <a href="/tags/commonjs/" style="font-size: 12.31px;">commonjs</a> <a href="/tags/database/" style="font-size: 16.92px;">database</a> <a href="/tags/docker/" style="font-size: 13.85px;">docker</a> <a href="/tags/dubbo/" style="font-size: 10px;">dubbo</a> <a href="/tags/fastdfs/" style="font-size: 10px;">fastdfs</a> <a href="/tags/gclib/" style="font-size: 10.77px;">gclib</a> <a href="/tags/geohash/" style="font-size: 10px;">geohash</a> <a href="/tags/gis/" style="font-size: 10px;">gis</a> <a href="/tags/git/" style="font-size: 10.77px;">git</a> <a href="/tags/go/" style="font-size: 10px;">go</a> <a href="/tags/gradle/" style="font-size: 10px;">gradle</a> <a href="/tags/groovy/" style="font-size: 10px;">groovy</a> <a href="/tags/hadoop/" style="font-size: 10px;">hadoop</a> <a href="/tags/hessisan/" style="font-size: 11.54px;">hessisan</a> <a href="/tags/java/" style="font-size: 20px;">java</a> <a href="/tags/javassist/" style="font-size: 10px;">javassist</a> <a href="/tags/kafka/" style="font-size: 11.54px;">kafka</a> <a href="/tags/linux/" style="font-size: 12.31px;">linux</a> <a href="/tags/log/" style="font-size: 17.69px;">log</a> <a href="/tags/log4j/" style="font-size: 12.31px;">log4j</a> <a href="/tags/logback/" style="font-size: 13.08px;">logback</a> <a href="/tags/map/" style="font-size: 10px;">map</a> <a href="/tags/memecached/" style="font-size: 10.77px;">memecached</a> <a href="/tags/mina/" style="font-size: 13.08px;">mina</a> <a href="/tags/mongodb/" style="font-size: 19.23px;">mongodb</a> <a href="/tags/mq/" style="font-size: 13.85px;">mq</a> <a href="/tags/mqtt/" style="font-size: 10.77px;">mqtt</a> <a href="/tags/mybatis/" style="font-size: 16.15px;">mybatis</a> <a href="/tags/netty/" style="font-size: 10px;">netty</a> <a href="/tags/nginx/" style="font-size: 11.54px;">nginx</a> <a href="/tags/nio/" style="font-size: 13.08px;">nio</a> <a href="/tags/nodejs/" style="font-size: 10px;">nodejs</a> <a href="/tags/postgresql/" style="font-size: 10.77px;">postgresql</a> <a href="/tags/protobuf/" style="font-size: 10px;">protobuf</a> <a href="/tags/proxy/" style="font-size: 10px;">proxy</a> <a href="/tags/push/" style="font-size: 10px;">push</a> <a href="/tags/rabbitmq/" style="font-size: 11.54px;">rabbitmq</a> <a href="/tags/redis/" style="font-size: 13.85px;">redis</a> <a href="/tags/rpc/" style="font-size: 19.23px;">rpc</a> <a href="/tags/sitemesh/" style="font-size: 10px;">sitemesh</a> <a href="/tags/sld/" style="font-size: 10px;">sld</a> <a href="/tags/slf4j/" style="font-size: 10px;">slf4j</a> <a href="/tags/socket/" style="font-size: 14.62px;">socket</a> <a href="/tags/spatialite-for-android/" style="font-size: 10px;">spatialite for android</a> <a href="/tags/spi/" style="font-size: 10px;">spi</a> <a href="/tags/spring/" style="font-size: 18.46px;">spring</a> <a href="/tags/tomcat/" style="font-size: 10.77px;">tomcat</a> <a href="/tags/transaction/" style="font-size: 10px;">transaction</a> <a href="/tags/web/" style="font-size: 10px;">web</a> <a href="/tags/xSocket/" style="font-size: 14.62px;">xSocket</a> <a href="/tags/zbus/" style="font-size: 10px;">zbus</a> <a href="/tags/zookeeper/" style="font-size: 10.77px;">zookeeper</a> <a href="/tags/数据结构/" style="font-size: 10.77px;">数据结构</a>
    </div>
  </div>

  
    
  <div class="widget-wrap">
    <h3 class="widget-title">Archives</h3>
    <div class="widget">
      <ul class="archive-list"><li class="archive-list-item"><a class="archive-list-link" href="/archives/2016/01/">January 2016</a><span class="archive-list-count">67</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2015/12/">December 2015</a><span class="archive-list-count">81</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2015/11/">November 2015</a><span class="archive-list-count">2</span></li></ul>
    </div>
  </div>

  
    
  <div class="widget-wrap">
    <h3 class="widget-title">Recents</h3>
    <div class="widget">
      <ul>
        
          <li>
            <a href="/2016/01/30/资料/">(no title)</a>
          </li>
        
          <li>
            <a href="/2016/01/30/java/13.Classloader系列一/">ClassLoader系列一</a>
          </li>
        
          <li>
            <a href="/2016/01/29/hadoop/1.hadoop系列之源码编译/">hadoop系列一之源码编译</a>
          </li>
        
          <li>
            <a href="/2016/01/29/go/1.GO系列之入门/">Go系列一之入门</a>
          </li>
        
          <li>
            <a href="/2016/01/28/tomcat/2.tomcat性能优化/">tomcat性能优化</a>
          </li>
        
      </ul>
    </div>
  </div>

  
</aside>
        
      </div>
      <footer id="footer">
  
  <div class="outer">
    <div id="footer-info" class="inner">
      &copy; 2016 John Doe<br>
      Powered by <a href="http://hexo.io/" target="_blank">Hexo</a>
    </div>
  </div>
</footer>
    </div>
    <nav id="mobile-nav">
  
    <a href="/" class="mobile-nav-link">Home</a>
  
    <a href="/archives" class="mobile-nav-link">Archives</a>
  
</nav>
    


<script src="http://libs.baidu.com/jquery/2.0.3/jquery.min.js"></script>


  <link rel="stylesheet" href="/fancybox/jquery.fancybox.css" type="text/css">
  <script src="/fancybox/jquery.fancybox.pack.js" type="text/javascript"></script>


<script src="/js/script.js" type="text/javascript"></script>

  </div>
</body>
</html>